﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ARS.Control.Custom.Entity.Fields;

namespace ARS.Control.Custom.Entity.Forms
{
    public class RequestQueryForm:Form
    {
        protected override void RenderContents(System.Web.UI.HtmlTextWriter output)
        {
            RequestQueryField field = (RequestQueryField) base.Field;
            if (field.IsTrShow)
            {
                string value = field.GetValue();
                if (field.TrShowSql != null)
                {
                    var reader = ARS.DataBase.Provider.DbFactory.DbProvider.ExecuteReader(string.Format(field.TrShowSql,value ));
                    if (reader.Read())
                    {
                        output.Write(string.Format(base.GetTrHtml(), reader[0]));
                    }
                }
                else
                {
                    output.Write(string.Format(base.GetTrHtml(), value));
                }

            }
            
            //base.RenderContents(output);
        }
    }
}
